package br.com.treinaweb.parte1;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class Tela3 extends Activity implements OnItemClickListener {
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tela3);
		
		Intent intent = getIntent();
		
		Bundle args = intent.getExtras();
		
		String nome = args.getString("nome");
		
		TextView viewNome = (TextView) findViewById(R.id.textView1);
		viewNome.setText("Aluno: " + nome);
		
		
		String[] cursos = getResources().getStringArray(R.array.cursos);
		ArrayAdapter<String> aAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_gallery_item, cursos);
	    
		ListView list = (ListView) findViewById(R.id.listViewCursos);
		list.setAdapter(aAdapter);
		
		list.setOnItemClickListener(this);
	}
	
	public void voltar(View v) {
		finish();
	}
	
	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		TextView resposta = (TextView) findViewById(R.id.textViewResposta2);
		String curso = ((TextView) view).getText().toString();
		
		resposta.setText("Resposta: " + curso);
	}
	

}
